<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<base href="<%=basePath%>"/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>库存管理</title>
		<link rel="stylesheet" href="res/layui/css/layui.css">
		<script src="res/js/jquery-2.1.4.min.js" type="text/javascript" ></script>
		<script src="res/layui/layui.js"></script>
	</head>
	<body>
	<div>
		药品种类：
		<div class="layui-inline" style="width: 140px;">
			<input class="layui-input" id="typeName" name="typeName" placeholder="药品种类"
				autocomplete="off">
		</div>
		药品名称：
		<div class="layui-inline" style="width: 140px;">
			<input class="layui-input" id="wareName" name="wareName" placeholder="药品名称"
				autocomplete="off">
		</div>
	</div>
	<br>
	<div>	
		药品数量：
		<div class="layui-inline" style="width: 140px;">
				<input class="layui-input" id="minNum" name="minNum" placeholder="最小数量"
				autocomplete="off">
		</div>
		<div class="layui-inline">~</div>
		<div class="layui-inline" style="width: 140px;">
			<input class="layui-input" id="maxNum" name="maxNum" placeholder="最大数量"
				autocomplete="off">
		</div>
		
		
		<button class="layui-btn" data-type="reload" onclick="reloadData()">搜索</button>
		
	</div>
	<table class="layui-table" id="inventory" lay-filter="demo"></table> 
	
	
	<script type="text/html" id="demo">
  <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
	</script>
	<script type="text/javascript">
		var table;

		var loadIndex;

		layui.use([ 'table' ], function() {

			table = layui.table;
			loadIndex = layer.load();
			//方法级渲染
			table.render({
				loading : true,
				id : 'inventory',
				page : true,
				height : 383,
				size : "sm",
				elem : '#inventory',
				url : 'stock/showAll.action',
				method : 'post',
				where : {

				},
				cols : [ [ {
					field : 'TYPE_NAME',
					title : '药品种类',
					width : 100,
					align : 'center',
					sort : true
				}, {
					field : 'WARE_NAME',
					title : '药品名称',
					width : 150,
					align : 'center',
					sort : true
				}, {
					field : 'inventory_num',
					title : '药品数量',
					width : 150,
					align : 'center',
					sort : true
				}, {
					field : 'WARE_FACTORY',
					title : '制药厂家',
					width : 300,
					align : 'center',
					sort : true
				}] ]

				,
				done : function(res, curr, count) {
					layer.close(loadIndex);//加载层关闭  
				}
			});

			

			$('.demoTable .layui-btn').on('click', function() {
				var type = $(this).data('type');
				active[type] ? active[type].call(this) : '';
			});
		});
		
		function reloadData(){
			table.reload('inventory', {
				where : {
					'typeName' : $("#typeName").val(),
					'wareName' : $("#wareName").val(),
					'maxNum' : $("#maxNum").val(),
					'minNum' : $("#minNum").val()
				}
			});
		}
		
	</script>

</body>
</html>